package com.shenmazong.serverwebpoem.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.shenmazong.serverwebpoem.mapper.ITbPoetryInfoMapper;
import com.shenmazong.serverwebpoem.pojo.TbPoetryInfo;
import com.shenmazong.serverwebpoem.service.TbPoetryInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 田不平
 * @project server-web-poem
 * @date 2020/3/24 9:01 AM
 * http://www.shenmazong.com
 */

@Slf4j
@Service
public class TbPoetryInfoServiceImpl implements TbPoetryInfoService {

    @Autowired
    ITbPoetryInfoMapper iTbPoetryInfoMapper;

    @Override
    public void add(TbPoetryInfo poetryInfo) {
        iTbPoetryInfoMapper.insert(poetryInfo);
    }

    @Override
    public void del(Integer id) {
        iTbPoetryInfoMapper.deleteById(id);
    }

    @Override
    public void set(TbPoetryInfo collection) {
        iTbPoetryInfoMapper.updateById(collection);
    }

    @Override
    public TbPoetryInfo getById(Integer id) {
        return iTbPoetryInfoMapper.selectById(id);
    }

    @Override
    public TbPoetryInfo getByPoetryId(Integer id) {
        QueryWrapper<TbPoetryInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("poetryid", id);

        return iTbPoetryInfoMapper.selectOne(queryWrapper);
    }
}

